import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/response/activity/actvity_recommend_list_data.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/viewmodel/new_activity/volunteer_sign_in_view_model.dart';
import 'package:ls_work/widgets/bottom_input_widget.dart';
import 'package:ls_work/widgets/title_value_widget.dart';

import '../../widgets/activity_widget.dart';

class VolunteerSignInPage extends BaseStatefulMvvmWidget{
  final ActvityRecommendListData data;
  VolunteerSignInPage(this.data);

  @override
  State<StatefulWidget> createState() => _VolunteerSignInState();

}

class _VolunteerSignInState extends BaseMvvmState<VolunteerSignInViewModel,VolunteerSignInPage>{
  @override
  Widget buildLoadingContentView() {
    return Column(
      children: [
        ListView(
          children: [
            TitleValueWidget("志愿者姓名",hint: '请选择',isRequired: true,text: viewModel.old?.name??"",).onTap(() {
              viewModel.selectOld();
            }),
            TitleValueWidget("联系方式",hint: '请输入',isRequired: true,text: viewModel.mobile,).onTap(() {
              showBottomInput(context,hint: "请输入联系方式",content: viewModel.mobile,keyboard: CommonInputType.phone,onSubmit: (str){
                setState(() {
                  viewModel.mobile = str;
                });
              });
            }),
            ...ActivityWidget.activityIndfoWidget(viewModel.contentList),
          ],
        ).setWeight(1),

        TextButton(onPressed: (){
          viewModel.submitEnroll();
        }, child: CommonText('提交',textColor: Colors.white),
        style: ButtonStyle(
          backgroundColor: WidgetStateProperty.all(Colours.app_main),
          minimumSize: WidgetStateProperty.all(Size.fromHeight(45)),
          shape: WidgetStateProperty.all(StadiumBorder())
        ),).addToContainer(margin: EdgeInsets.symmetric(horizontal: 16,vertical: 10),width: MediaQuery.of(context).size.width)
      ],
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(title: Text('志愿者报名'),),
      body: loadingContentWidget,
    );
  }

  @override
  VolunteerSignInViewModel createViewModel() {
    return VolunteerSignInViewModel(context,widget.data);
  }

  @override
  void onRetryClick() {
  }

}